package com.byd.dms.demo;

import cn.hutool.http.HttpUtil;
import com.byd.dms.entity.Dept;
import com.byd.dms.entity.User;
import org.junit.jupiter.api.Test;

import java.util.*;

public class DemoTest1 {
    
    
    private static Dept dept;
    
    
    private static User user;
    
    static {
        
        
        user = new User("刘阿勇", 18, "男");
        Dept dept2 = new Dept(5L, "测试部", 52);
        user.setDept(dept2);
        user.setHobbies(Arrays.asList("吃饭", "睡觉", "乌拉圈"));
        
        dept = new Dept(3L, "开发部", 38);
        User user1 = new User("秦疆1号", 3, "男");
        User user2 = new User("秦疆2号", 3, "男");
        User user3 = new User("秦疆3号", 3, "男");
        
        List<User> list = new ArrayList<User>();
        list.add(user1);
        list.add(user2);
        list.add(user3);
        
        dept.setUsers(list);
        
    }
    
    /**
     * 传递user对象 和 dept对象
     */
    @Test
    public void test1() {
        
        System.out.println("user = " + user);
        System.out.println("dept = " + dept);
        
        Map<String, Object> map = new HashMap<>();
        map.put("type", "testDemo");
        map.put("user", user);
        map.put("dept", dept);
        map.put("city", "北京");
        map.put("time", System.currentTimeMillis());
        
        System.out.println("map = " + map);
        
        // 直接发一个map
        String result = HttpUtil.post("http://localhost:8080/http/user", map);
    
        System.out.println("result = " + result);
    }
    
}
